import json
from xml.etree import ElementTree

def convert_to_json(s):
    return json.dumps(convert_to_structure(s), sort_keys=True, indent=4)

def convert_to_structure(s):
    root = ElementTree.fromstring(s)
    return convert_element(root)
    
def convert_element(el):
    res = {}
    if el.tag[0]=="{":
        ns, name = el.tag.rsplit("}",1) 
        res["tag"] = name
        res["namespace"] = ns[1:]
    else:
        res["tag"] = el.tag
    for k,v in el.items():
        res["@"+k] = v
    kids = []
    if el.text:
        kids.append(el.text)
    for kid in el:
        kids.append(convert_element(kid))
        if kid.tail:
            kids.append(kid.tail)
    if len(kids):
        res["children"] = kids
    return res
